package com.hhsj.dynamicui.server.server;


import com.hhsj.dynamicui.server.utils.ConstantUtil;

/**
 * 用于启动Wifi，等待连接
 */
public class WifiService {

    private ListenThread listenThread;

    //启动监听线程
    public void startWaitDataThread() {
        if (listenThread != null) {
            if (listenThread.getState() != Thread.State.NEW) {
                try {
                    listenThread.interrupt();
                    listenThread = null;
                } catch (Exception E) {
                    //do nothing
                } finally {
                    listenThread = null;
                }
                listenThread = new ListenThread(ConstantUtil.PORT);
            }
        } else {
            listenThread = new ListenThread(ConstantUtil.PORT);
        }
        listenThread.start();

    }


    public void stopThread() {
        try {
            if (listenThread != null) {
                listenThread.shutDown();
                listenThread = null;
            }
        } catch (Exception e) {
            // do nothing
        }
    }

}